﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ProjetAGL
{
    public partial class Score : Form
    {
        public Score()
        {
            InitializeComponent();
            string[] scores = System.IO.File.ReadAllLines(@"C:\Mixmo\scores.txt");
            Array.Sort(scores);
            Array.Reverse(scores);
            label1.Text = scores[0];
            label2.Text = scores[1];
            label3.Text = scores[2];
            label4.Text = scores[3];
            label5.Text = scores[4];
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public void enregistrerScore(Joueur param_joueurEnCours)
        {
            string[] score = new string[5];
            string[] score2 = new string[6];
            string[] scoresAEcrire = new string[5];
            score = System.IO.File.ReadAllLines(@"C:\Mixmo\scores.txt");

            for (int i = 0; i < 5; i++)
                score2[i] = score[i];


            score2[5] = param_joueurEnCours.DernierScore + "_" + param_joueurEnCours.NomJoueur;

            Array.Sort(score2);
            Array.Reverse(score2);

            for (int i = 0; i < 5; i++)
                scoresAEcrire[i] = score2[i];

            System.IO.File.WriteAllLines(@"C:\Mixmo\scores.txt", scoresAEcrire);

        }

        
    }
}
